Skip to content

fix(FormatExtension/Gradle): Fix step setup with toggleFence and targetExcludeContentPattern #2487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

snazy
Copy link
Contributor

@snazy snazy commented May 21, 2025

With a non-null toggleFence, com.diffplug.gradle.spotless.FormatExtension#setupTask creates a new List via List.of(). Also having a non-null targetExcludeContentPattern leads to an UnsupportedOperationException thrown by List.replaceAll, because List.of yields an immutable list.

The issue is reproducible via:

spotless {
  java {
    licenseHeader('// my-copyright')
    toggleOffOn() // adds the 'toggleFence'
    targetExcludeIfContentContains('excludeMe') // adds the 'targetExcludeContentPattern'
  }

Change includes (integeration) tests.

snazy added 2 commits May 21, 2025 12:27
…argetExcludeContentPattern`

With a non-null `toggleFence`, `com.diffplug.gradle.spotless.FormatExtension#setupTask` creates a new `List` via `List.of()`. Also having a non-null `targetExcludeContentPattern` leads to an `UnsupportedOperationException` thrown by `List.replaceAll`, because `List.of` yields an immutable list.

Change includes (integeration) tests.
@snazy
Copy link
Contributor Author

snazy commented May 21, 2025

Hm, is the spotlessCheck CI failure accurate? Mean, I can apply the formatting change 🤷
Ouch - I see the issue

@nedtwigg nedtwigg merged commit 281e12f into diffplug:main May 21, 2025
16 checks passed
@snazy snazy deleted the format-extension-target-content-exclude-pattern branch May 21, 2025 16:11
@snazy
Copy link
Contributor Author

snazy commented May 21, 2025

Thanks for the quick review + merge!
Really appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants